package com.example.android09_preference;

import org.xmlpull.v1.XmlSerializer;

import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.Menu;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

public class MainActivity extends Activity {

	TextView intercall;
	TextView rTone;
	TextView sleepMode;
	ImageButton setting;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		intercall = (TextView) findViewById(R.id.interCall);
		rTone = (TextView) findViewById(R.id.rtone);
		sleepMode=(TextView) findViewById(R.id.sleepmode);
		setting = (ImageButton) findViewById(R.id.settings);
		
		setting.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(MainActivity.this,EditActivity.class);
				startActivity(intent);
				
				
			}
		});
		
	}
	
	@Override
	protected void onResume() {
		
		super.onResume();
		SharedPreferences sharedPreferences= PreferenceManager.getDefaultSharedPreferences(this);
		intercall.setText(new Boolean(sharedPreferences.getBoolean("interCall", false)).toString());
		rTone.setText(sharedPreferences.getString("ringtone", "nothing"));
		sleepMode.setText(new Boolean(sharedPreferences.getBoolean("sleepMode", false)).toString());
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

}
